﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using CommunitySystem.Assert;

namespace CommunitySystem.Views
{
    public interface IAsyncCtrl
    {
        string Title { get; set; }
        bool PageLoaded { get; set; }
        NavMoveSwitch Nav { get; set; }
    }

    public class AsyncCtrl : UserControl, IAsyncCtrl
    {
        public NavMoveSwitch Nav { get; set; }

        public virtual string Title { get; set; }

        private bool _dataLoaded = false;
        private bool _pageLoaded = false;

        protected bool DataLoaded
        {
            get { return _dataLoaded; }
            set { _dataLoaded = value; LoadData(); }
        }

        public bool PageLoaded
        {
            get { return _pageLoaded; }
            set { _pageLoaded = value; LoadData(); }
        }

        private void LoadData()
        {
            if (_pageLoaded && _dataLoaded)
            {
                PageDataLoaded();
            }
        }

        protected virtual void PageDataLoaded()
        {
            
        }
    }
}
